package com.lagou;

import com.lagou.impl.LagouPlayManager;
import com.lagou.impl.LagouPlayer;

import java.util.concurrent.ThreadLocalRandom;

/**
 * @author mcl
 * @date 2021/12/29 14:28
 * @description
 */
public class PlayerTest {
    public static void main(String[] args) throws InterruptedException {
        LagouPlayManager playManager = LagouPlayManager.getInstance();

        while (true) {

            LagouPlayer lagouPlayer = new LagouPlayer("Player_".concat(String.valueOf(ThreadLocalRandom.current().nextInt())));
            playManager.addPlayer(lagouPlayer);

            if (ThreadLocalRandom.current().nextBoolean()) {
                playManager.broadcast("Send Boradmessage: ".concat(String.valueOf(ThreadLocalRandom.current().nextInt())));
            }

            playManager.removeOfflinePlayer();

            Thread.sleep(5000);
        }
    }
}
